<html>
<head><meta charset="utf-8"><title>Zero copy fs writes for miri · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Zero.20copy.20fs.20writes.20for.20miri.html">Zero copy fs writes for miri</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="178915950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Zero%20copy%20fs%20writes%20for%20miri/near/178915950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Zero.20copy.20fs.20writes.20for.20miri.html#178915950">(Oct 24 2019 at 02:36)</a>:</h4>
<p>Hello, I've been thinking about <a href="https://github.com/rust-lang/miri/issues/1007" target="_blank" title="https://github.com/rust-lang/miri/issues/1007">https://github.com/rust-lang/miri/issues/1007</a> and I wanted to build a solution that allows to implement the <code>read</code> and <code>write</code> shims for unix without having to write to intermediate buffers.</p>



<a name="178916185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Zero%20copy%20fs%20writes%20for%20miri/near/178916185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Zero.20copy.20fs.20writes.20for.20miri.html#178916185">(Oct 24 2019 at 02:42)</a>:</h4>
<p>My first naive solution would be to do an <code>Allocation::get_mut</code> wrapper inside <code>Memory</code> that checks bounds just like  <code>Memory::write_bytes</code> does (of course this might end in an horrible way, I haven't thought about the implications)</p>



<a name="178916212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Zero%20copy%20fs%20writes%20for%20miri/near/178916212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Zero.20copy.20fs.20writes.20for.20miri.html#178916212">(Oct 24 2019 at 02:43)</a>:</h4>
<p>As an alternative for <code>read</code>I might be able to do something with the <code>Read::bytes</code> method, but that consumes the file itself so... I don't have high hopes in that direction.</p>



<a name="178916231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Zero%20copy%20fs%20writes%20for%20miri/near/178916231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Zero.20copy.20fs.20writes.20for.20miri.html#178916231">(Oct 24 2019 at 02:44)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> , <span class="user-mention" data-user-id="124288">@oli</span> let me know what you think :)</p>



<a name="178927888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Zero%20copy%20fs%20writes%20for%20miri/near/178927888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Zero.20copy.20fs.20writes.20for.20miri.html#178927888">(Oct 24 2019 at 07:37)</a>:</h4>
<blockquote>
<p>My first naive solution would be to do an Allocation::get_mut wrapper inside<br>
Memory that checks bounds just like Memory::write_bytes does</p>
</blockquote>
<p><code>get_mut</code> still has a subtle contract: the caller must actually write to all the<br>
bytes in the given range.<br>
I would say, for us to do optimizations that involve exposing subtle APIs like<br>
that, I'd first like to see benchmarks demonstrating that this cost is worth the<br>
benefit.</p>
<p>(Just a quick reply via email; I'm too busy for Zulip for another week I'm afraid.)</p>



<a name="178952545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Zero%20copy%20fs%20writes%20for%20miri/near/178952545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Zero.20copy.20fs.20writes.20for.20miri.html#178952545">(Oct 24 2019 at 13:43)</a>:</h4>
<p>Yes the subtle contract part was what I was worrying about</p>



<a name="178952567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Zero%20copy%20fs%20writes%20for%20miri/near/178952567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Zero.20copy.20fs.20writes.20for.20miri.html#178952567">(Oct 24 2019 at 13:43)</a>:</h4>
<p>I'm going to go first for the  correct way and then we can think about the fast way :P</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>